<template>
  <el-drawer v-model="_isOpen" class="jzt-drawer pay_detail_drawer" size="450" @close="_isOpen = false">
    <template #header>
      <div class="drawer_head">
        <div class="round" />
        采购单付款明细
      </div>
    </template>
    <template v-for="item in detailInfo" :key="item.purchaseOrderId + index">
      <div class="pay_info_box">
        <div class="box_head">
          <img src="@/assets/images/pay_info_icon.png" />
          {{ item.time }}
        </div>
        <div class="box_content">
          <div class="content_row">
            <div class="row_label">关联合作方</div>
            <div class="row_text">{{ item.factoryName }}</div>
          </div>
          <div class="content_row">
            <div class="row_label">关联采购单</div>
            <div class="row_text">{{ item.purchaseOrderNo }}</div>
          </div>
          <div class="content_row">
            <div class="row_label">实付金额</div>
            <div class="row_text row_price">￥{{ item.payAmount }}</div>
          </div>
        </div>
      </div>
    </template>
    <div v-if="detailInfo.length === 0" class="empty_box">
      <el-empty description="暂无内容" />
    </div>
  </el-drawer>
</template>
<script setup>
import { getPayInfo } from "@/apis/order";
import { computed, ref } from "vue";

const props = defineProps({
  modelValue: { type: Boolean, default: false },
  orderId: { type: String, default: "" }
});

const emit = defineEmits(["update:modelValue"]);

const _isOpen = computed({
  get: () => props.modelValue,
  set: newVal => emit("update:modelValue", newVal)
});

const detailInfo = ref({});

const getPayInfoDetail = async () => {
  const { data } = await getPayInfo(props.orderId);
  detailInfo.value = data;
};

(() => {
  getPayInfoDetail();
})();
</script>
<style lang="scss" scoped>
.pay_detail_drawer {
  .drawer_head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    color: #131414;
    line-height: 24px;
    .round {
      width: 6px;
      height: 6px;
      background-color: #409eff;
      border-radius: 50%;
    }
  }
  .pay_info_box {
    background: #f4f6f8;
    border-radius: 10px;
    margin-bottom: 10px;
    .box_head {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      color: #3d3d3d;
      line-height: 22px;
      padding: 5px 20px;
      border-bottom: 1px solid #e2e8f0;
    }
    .box_content {
      display: grid;
      gap: 10px;
      padding: 10px 20px;
      .content_row {
        display: flex;
        justify-content: space-between;
        .row_label {
          font-size: 13px;
          color: #86909c;
          line-height: 22px;
        }
        .row_text {
          font-size: 13px;
          color: #3d3d3d;
          line-height: 22px;
        }
        .row_price {
          color: #ff3333;
        }
      }
    }
  }
  .empty_box {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
  }
}
</style>
